#include "Tuple.h"
#include "IVisitor.h"

Tuple::Tuple(const ExprTypeList& elts, int ctx, bool endsWithComma, int nodeId):
    exprType(nodeId),
    _elts(elts),
    _ctx(ctx),
    _endsWithComma(endsWithComma)
{
}
    
Tuple::~Tuple()
{
    _elts.clear();
}
    
QString Tuple::type() const
{
    return "Tuple";
}
    

ExprTypeList Tuple::elts()
{
    return _elts;
}

void Tuple::setElts(const ExprTypeList& elts)
{
    _elts = elts;
}

int Tuple::ctx()
{
    return _ctx;
}

void Tuple::setCtx(int ctx)
{
    _ctx = ctx;
}

bool Tuple::endsWithComma()
{
    return _endsWithComma;
}

void Tuple::setEndsWithComma(bool endsWithComma)
{
    _endsWithComma = endsWithComma;
}

    
QString Tuple::toString() const
{
    return QString("Tuple[elts=%1, ctx=%2, endsWithComma=%3]").
                arg(_elts.toString()).
                arg(_ctx).
                arg(_endsWithComma);
}
    
void Tuple::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitTuple(node.dynamicCast<Tuple>());
}
    
void Tuple::traverse(IVisitor* visitor)
{
    _elts.traverse(visitor);
}